package com.shen.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker  //添加对熔断的支持  CircuitBreaker 断路器
public class Hystrix_8001 {
    public static void main(String[] args) {
        SpringApplication.run(Hystrix_8001.class,args);
    }
    @Bean
    public ServletRegistrationBean hystrixHystrixMetricsStreamServlet(){
        ServletRegistrationBean registrationBean = new ServletRegistrationBean(new HystrixMetricsStreamServlet());
        registrationBean.setLoadOnStartup(1);//启动级别为一级
        registrationBean.addUrlMappings("/actuator/hystrix.stream");//监控页面
        registrationBean.setName("Hystrix_8001");//设置名称
        return registrationBean;

    }
}
